﻿<%@ Page Title="" Language="C#" MasterPageFile="~/template_faa/master/faa.master" AutoEventWireup="true" %>

<asp:Content ID="Content1" ContentPlaceHolderID="head" runat="server">
<style type="text/css">  
    #fm{ margin:0; padding:10px 30px; }  
    .ftitle{ font-size:14px; font-weight:bold; padding:5px 0; margin-bottom:10px; border-bottom:1px solid #ccc; }  
    .fitem{ margin-bottom:5px; }  
    .fitem label{ display:inline-block; width:100px; }  
    .fitem input,textarea{ width:480px; }
</style>  
</asp:Content>

<asp:Content ID="Content2" ContentPlaceHolderID="body" runat="server">
    <div class="clear  wide" id="bodyPadding">
        <!--左侧导航栏-->
        <div id="vNav">
            <ul class="Sle S2">
                <li>
                    <h4>基元项目</h4>
                    <ul>
                        <li><a class="here" href="#">浏览项目</a></li>
                        <li><a href="#">管理项目</a></li>
                    </ul>
                </li>
            </ul>
            <ul class="Sle S2">
                <li>
                    <h4>基元内容</h4>
                    <ul>
                        <li><a class="here" href="#">浏览内容</a></li>
                        <li><a href="#">管理内容</a></li>
                    </ul>
                </li>
            </ul>
        </div>
        
        <!--右上快速链接栏-->
        <div class="clear" id="breadcrumbs">
            <p>
                <a href="#">信息维护</a> <span>»</span> <a href="#">通用信息</a> <span>»</span>执法单位信息
            </p>
        </div>
        
        <!--右下主体栏-->
        <div class="whiteSheet">
            <div class="content" id="content_01">
	            <h1 class="pageTitle">执法单位信息维护</h1>
	            <div class="demo-info">
		            <div class="demo-tip icon-tip"></div>
		            <div>可以新增，编辑或者删除执法单位信息</div>
	            </div>
	            
	            <div id="tb" style="padding:5px;height:auto">  
                    <div style="margin-bottom:5px">  
                        <a href="javascript:void(0)" class="easyui-linkbutton" iconCls="icon-add" plain="true" onclick="newItem()">新增</a>  
                        <a href="javascript:void(0)" class="easyui-linkbutton" iconCls="icon-edit" plain="true" onclick="editItem()">编辑</a>  
                        <a href="javascript:void(0)" class="easyui-linkbutton" iconCls="icon-remove" plain="true" onclick="delItem()">删除</a>  
                    </div>  
                </div>  
            	
                <table id="dg" class="easyui-datagrid" style="width:700px;height:400px"  
                        url="/template_faa/handler/grid.ashx?view=zhifaDW" 
                        title="执法单位信息列表" singleSelect="true" toolbar="#tb"
                        rownumbers="false" pagination="true" pageSize="10" singleSelect="true">  
                    <thead>  
                        <tr>  
                            <th field="zfdwName" width="120">单位名称</th>  
                            <th field="zfdwAbbr" width="100">单位简称</th>  
                            <th field="zfdwAddr" width="240">地址</th>  
                            <th field="zfdwLinkman" width="80">联系人</th>  
                            <th field="zfdwTel" width="100">联系电话</th>
                            <th field="zfdwId" width="100" hidden="true">不公开</th>
                        </tr>  
                    </thead>  
                </table>
                
                <div id="dlg" class="easyui-dialog" style="width:500px;height:400px;padding:10px 20px"  
                    closed="true" buttons="#dlg-buttons">  
                <div class="ftitle">请输入执法单位信息</div>  
                    <form id="fm" method="post" novalidate>  
                        <div class="fitem">  
                            <label>单位名称：</label><br />  
                            <input name="zfdwName" class="easyui-validatebox" required="true"> 
                        </div>  
                        <div class="fitem">  
                            <label>单位简称：</label><br />  
                            <input name="zfdwAbbr" class="easyui-validatebox" required="true">  
                        </div>  
                        <div class="fitem">  
                            <label>地址：</label><br />  
                            <input name="zfdwAddr" class="easyui-validatebox" required="true">  
                        </div>  
                        <div class="fitem">  
                            <label>联系人：</label><br />  
                            <input name="zfdwLinkman" class="easyui-validatebox" required="true">  
                        </div>  
                        <div class="fitem">  
                            <label>联系电话：</label><br />  
                            <input name="zfdwTel" class="easyui-validatebox" required="true">  
                        </div>  
                    </form>  
                </div>  
                <div id="dlg-buttons">  
                    <a href="javascript:void(0)" class="easyui-linkbutton" iconCls="icon-ok" 
                        onclick="saveItem()">保存</a>  
                    <a href="javascript:void(0)" class="easyui-linkbutton" iconCls="icon-cancel" 
                        onclick="javascript:$('#dlg').dialog('close')">取消</a>  
                </div>
                <script type="text/javascript">
                    var url;
                    function newItem() {
                        $('#dlg').dialog('open').dialog('setTitle', '新增执法单位信息');
                        $('#fm').form('clear');
                        url = '/template_faa/handler/ajax.ashx?view=zhifadw&action=insert';
                    }
                    function editItem() {
                        var row = $('#dg').datagrid('getSelected');
                        if (row) {
                            $('#dlg').dialog('open').dialog('setTitle', '编辑执法单位信息');
                            $('#fm').form('load', row);
                            url = '/template_faa/handler/ajax.ashx?view=zhifadw&action=update&id=' + row.zfdwId;
                        }
                    }
                    function saveItem() {
                        $('#fm').form('submit', {
                            url: url,
                            onSubmit: function() {
                                return $(this).form('validate');
                            },
                            success: function(result) {
                                var result = eval('(' + result + ')');
                                if (result.errorMsg) {
                                    $.messager.show({
                                        title: 'Error',
                                        msg: result.errorMsg
                                    });
                                } else {
                                    $('#dlg').dialog('close');      // close the dialog
                                    $('#dg').datagrid('reload');    // reload the user data 
                                    $.messager.alert('提示', '保存成功', 'info');
                                }
                            }
                        });
                    }
                    function delItem() {
                        var row = $('#dg').datagrid('getSelected');
                        if (row) {
                            $.messager.confirm('提示', '您确认要删除该执法单位信息吗？', function(r) {
                                if (r) {
                                    $.post('/template_faa/handler/ajax.ashx?view=zhifadw&action=delete', { id: row.zfdwId }, function(result) {
                                        if (result.errorMsg) {
                                            $.messager.show({   // show error message  
                                                title: 'Error',
                                                msg: result.errorMsg
                                            });
                                        } else {
                                            $('#dg').datagrid('reload');    // reload the user data  
                                        }
                                    }, 'json');
                                }
                            });
                        }
                    }                
                </script>  
            </div>
        </div>
    </div>
    
</asp:Content>
